<?php
namespace App\Http\Controllers\Myself;
use Illuminate\Http\Request;
use App\Http\Controllers\BaseApiController;
use Illuminate\Support\Facades\Validator;
use App\Services\Myself\CollectService;
class CollectController extends BaseApiController{
    private $service;
    public function __construct(CollectService $service){
        //继承基类的构造方法
        parent::__construct();
        //依赖注入service
        $this->service=$service;
    }
    /**
     * 获取我的收藏
     */
    public function CollectList(Request $request){
        //验证类型参数是否为数字已经是否为空
        $rule=[
            'type'=>'required|integer',
            'page'=>'integer|min:1'
        ];
        if($error=$this->validate($rule,$request)){
            return $error;
        }
        $type=$request->get('type');
        $page=$request->get('page',1);
        switch ($type){
            //咨询
            case 1:$arr=$this->service->CollectInfomation(1,$page);break;
            //职位
            case 3:$arr=$this->service->CollectPosition(1,$page);break;
            //公司
            case 5:$arr=$this->service->CollectEnterprise(1,$page);break;
        }
        return $arr;
    }

}